Data-Loading Functions
Compressors use the data-loading and data-unloading functions when working with images that do not fit into memory. The data-loading function supplies compressed data during a decompression operation.
The
DataProcPtr
data type defines a pointer to a data-loading function. You assign a data-loading function to an image or a sequence by passing a pointer to a structure that identifies the function to the appropriate decompress function.
/* data-loading function structure */
typedef struct ICMDataProcRecord ICMDataProcRecord;
typedef ICMDataProcRecord *ICMDataProcRecordPtr;
The data-loading function structure contains the following fields:
struct ICMDataProcRecord
{
ICMDataUPP dataProc; /* pointer to data-loading function */
long dataRefCon; /* reference constant */
};
-
dataProc
-
Contains a pointer to your data-loading function.
-
dataRefCon
-
Contains a reference constant for use by your data-loading function.
DESCRIPTION
If your data-loading function returns a nonzero result code, the Image Compression Manager terminates the current operation.
MyDataLoadingProc
Your data-loading function should have the following form:
pascal OSErr MyDataLoadingProc (Ptr *dataP, long bytesNeeded,
long refcon);
-
dataP
-
Contains a pointer to the address of the data buffer. The decompressor uses this parameter to indicate where your data-loading function should return the compressed data. You establish this data buffer when you start the decompression operation. For example, the
data
parameter to the
FDecompressImage
function (described on
FDecompressImage
) defines the location of the data buffer for that operation. Upon return from your data-loading function, this pointer should refer to the beginning of the compressed data that you loaded.
-
The decompressor may also use this parameter to indicate that it wants to reset the mark within the compressed data stream. If the
dataP
parameter is set to
nil
, the
bytesNeeded
parameter contains the new mark position, relative to the current position of the data stream. If your data-loading function does not support this operation, return a nonzero result code.
-
bytesNeeded
-
Specifies the number of bytes requested or the new mark offset. If the decompressor has requested additional compressed data (that is, the value of the
dataP
parameter is not
nil
), then this parameter specifies how many bytes to return. This value never exceeds the size of the original data buffer. Your data-loading function should read the data from the current mark in the input data stream.
-
If the decompressor has requested to set a new mark position in the data stream (that is, the value of the
dataP
parameter is
nil
), then this parameter specifies the new mark position relative to the current position of the data stream.
-
refcon
-
Contains a reference constant value for use by your data-loading function. Your application specifies the value of this reference constant in the data-loading function structure you pass to the Image Compression Manager.
SPECIAL CONSIDERATIONS
The pointer in the
dataP
parameter must contain a 32-bit clean address within the data buffer. If you have dereferenced a handle, you should call the Memory Manager's
StripAddress
routine before passing it to the
MyDataLoadingProc
function.
RESULT CODES
noErr
|
0
|
No error
|
paramErr
|
-50
|
Invalid parameter specified
|
codecSpoolErr
|
-8966
|
Error loading or unloading data
|
© 1999 Apple Computer, Inc.Previous | Overview | Contents | Next